
cc.Class({
    extends: cc.Component,

    properties: {
        Fy_NodeHall:cc.Node,
        Works:cc.Prefab,
        content:cc.Node,
        Works_0:cc.Node,
        Works_1:cc.Node,
        Works_2:cc.Node,
        Works_3:cc.Node,
        NewlyAddedWorks:cc.Node
    },
    oninfo(){
      this.node.active = true;
      this.onReplacePopular();
      this.onPostRank();
    },
    onReturn(){
        this.node.active = false;
        this.Fy_NodeHall.active = true;
        window.GameClubButton.show();
    },
    onReplacePopular(){  // 热门
      for(var i = 0 ; i<4;i++){
         this["Works_"+i].getComponent("Works").init(123,true);
      }
    },
    onPostRank(){ // 新增
        this.NewlyAddedWorks.removeAllChildren(true);
        var canshu = 10;
        var line = 0;
        for(var i = 0; i<canshu;i++){
            var RankItem = cc.instantiate(this.Works);
            RankItem.getComponent("Works").init(i,true);
            if(i%2 == 0){
                line = i == 0? 0 : Math.ceil(i/2);
                RankItem.y = -220-370*line;
                RankItem.x = -170; 
                this.NewlyAddedWorks.addChild(RankItem);
            }else{
                RankItem.y = -220-370*line;
                RankItem.x = 170; 
                this.NewlyAddedWorks.addChild(RankItem);
            }
            this.NewlyAddedWorks.height = Math.abs(-220-370*line-200);
        }
        this.content.height = 850 + this.NewlyAddedWorks.height;
    }
});
